<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/order_list.css')}}">
    <link rel="stylesheet" href="{{mix('/css/web/user/attention.css')}}">
    <link rel="stylesheet" href="{{mix('/css/web/user/store.css')}}">
    <script src="{{mix('/js/web/user/attention.js')}}"></script>
    <script>
        token = '{!! csrf_token() !!}';
    </script>
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.buyer_nav')
        <div class="nav_right flr">
            <div class="nav_tittle">
                <div class="line_title" style="border-bottom: 1px dashed #ccc;">我的收藏</div>
            </div>
            <div class="base_content box" style="padding: 1px 18px">
                <div class="my-subnav f-cb">
                    <ul>
                        <li class="collection @if(array_get($search_params,'type')==1) cur @endif">
                            <a href="/member/buyer/collection?type=1">商品收藏</a>
                        </li>
                        <li class="collection @if(array_get($search_params,'type')==2) cur @endif">
                            <a href="/member/buyer/collection?type=2">店铺收藏</a>
                        </li>
                    </ul>
                </div>
                <input type="hidden" name="type" value="{{array_get($search_params,'type')}}">
                {{--店铺收藏--}}
                @if(array_get($search_params,'type')==2)
                <div class="shop_collection" id="B1" style="display: block;position: relative;">
                    <div class="choose fl" style="top:-60px;">
                        <div class="check fl">
                            <label><input type="checkbox" class="allcheck1">全选</label>
                        </div>
                        <a href="javascript:void(0);" class="close fl deleteAll1 cancel">取消收藏</a>
                    </div>
                    @foreach($list as $key=>$value)
                    <div class="store_box">
                        <div class="store_left">
                            <div class="store_img">
                                <img width="150" src="{{array_get($value['shop'],'sp_logo')}}" alt="{{array_get($value['shop'],'sp_name')}}">
                            </div>
                            <div class="store_kinds" style="overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 3;-webkit-box-orient: vertical;">主营产品：
                                @if(count($value['business_product'])>0)
                                    @foreach($value['business_product'] as $k=>$v)
                                        <span class="kinds_name kinds_monitor">{{$v}}
                                        @if($k<(count($value['business_product'])-1))
                                            、
                                        @endif
                                        </span>
                                    @endforeach
                                @endif
                            </div>
                            <div class="store_serve">
                                 <div class="attentionbox fl" style="border-top:0;">
                                    <div class="check fl">
                                        <input type="checkbox" data-id="{{$value['id']}}"  class="listcheck1" onclick="" >
                                    </div>
                                    <a href="javascript:;" data-id="{{$value['id']}}" class="close fl deletem1">取消收藏</a>
                                </div>
                                <a href="{{asset('/shop/index/'.$value['shop']['sp_id'])}}" target="_blank" class="more_message">更多信息></a>
                            </div>
                        </div>
                        <div class="store_right">
                            <div class="right_hot">
                                <p class="selling">热销</p>
                            </div>
                            <div class="anniu_left"></div>
                            <div class="anniu_right"></div>
                            <!-- 当商品数小于4个时去除store-swiper -->
                            <div class="swiper-container store-swiper">
                                <div class="swiper-wrapper">
                                    @if(count($value['hot_product'])>0)
                                        @foreach($value['hot_product'] as $k=>$v)
                                            <div class="swiper-slide right-swiper" style="margin-right: 0;">
                                                <a href="/product/info/{{$v['id']}}/0" target="_blank" style="text-decoration: none;color: #666;">
                                                <img width="115" height="135" class="hot-img" src="{{$v['cover_image']}}" alt="">
                                                <p class="img-explain">{{$v['name']}}</p>
                                                </a>
                                            </div>
                                        @endforeach
                                    @endif
                                </div>
                                <div class="swiper-button-prev swiper_btn"></div>
                                <div class="swiper-button-next swiper_btn"></div>
                            </div>
                        </div>
                    </div>
                    @endforeach
                    <div class="page">
                        @include('web.common.paginate')
                    </div>
                </div>
                @endif
                {{--商品收藏--}}
                @if(array_get($search_params,'type')==1)
                <div class="goods_collection" id="B1" style="position: relative;">
                    <div class="choose fl">
                        <div class="check fl">
                            <label><input type="checkbox" class="allcheck">全选</label>
                        </div>
                        <a href="javascript:void(0);" class="close fl deleteAll cancel">取消收藏</a>
                    </div>
                    <div class="content">
                        <div class="list">
                            <ul>
                                @if(count($list)>0)
                                @foreach($list as $key=>$value)
                                <li>
                                    <div class="imgbox">
                                        <a href="/product/info/{{$value['product_id']}}/{{$value['sku_id']}}" target="_blank">
                                            <img src="{{array_get($value['product'],'cover_image')}}" alt="" />
                                        </a>
                                    </div>
                                    <div class="price">￥{{array_get($value['sku'],'price')}}</div>
                                    <div class="name">
                                        <a href="" target="_blank">{{array_get($value['product'],'name')}}</a>
                                    </div>
                                    <div class="attention_buy">
                                        <div class="attentionbox fl">
                                            <div class="check fl">
                                                <input type="checkbox" name="store" data-id="{{$value['id']}}"  class="listcheck" onclick="">
                                            </div>
                                            <a href="javascript:;" data-id="{{$value['id']}}" class="close fl deletem">取消收藏</a>
                                        </div>
                                        <a href="javascript:void(0);" data-url="/member/buyer/orders/create?type=direct&sku_id={{$value['sku_id']}}&sku_num=1" class="buy fl" data-sku="{{$value['sku_id']}}" data-id="{{$value['sku_id']}}">立即购买</a>
                                    </div>
                                </li>
                                @endforeach
                                @else
                                    <p class="text-center">暂无收藏数据</p>
                                @endif
                            </ul>
                        </div>
                    </div>
                    <div class="page">
                        @include('web.common.paginate')
                    </div>
                </div>
                @endif
            </div>
        </div>
    </div>
</div>
@include('web.layout.footer')
<script>
     var mySwiper = new Swiper('.store-swiper', {
      slidesPerView: 4,
      navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
      },
    })
     // 立即购买商品检测
    $(document).on('click','.buy',function () {
        var _this = $(this);
        var url = _this.attr('data-url');
        var sku_id = _this.attr('data-id');
        console.log(url);
        // ajax 检测是否可以购买
        $.ajax({
            url:"/member/buyer/orders/checkBuyProduct/"+sku_id,
            type: "post",
            data: {sku_num:1},
            dataType:'json',
            success:function(data){
                if(0==data.code){
                    window.open(url);
                }else{
                    layer.alert(data.message,{icon: 2});
                }
            }
        });
    });
</script>
</body>
</html>